<?php
// safety check
	if(!isset($user) || !$user->isLoggedIn()) die();

// init module
	include $modules->controller();
	include $modules->lang();
	$modules->init();

// module actions
	if(isset($_POST['add'])) $act = $modules->add($_POST);
	if($del) $act = $modules->del($del);
	if(isset($_POST['edit'])) $act = $modules->edit($_POST, $edit);

// include header
	?>
	<div id="header">
		<div id="top">
			<div class="fl-l">
				<a href="<?php echo $cosa->system('site-url'); ?>/" class="homelink"><?php $lang->put('back-to-site'); ?></a>
			</div>
			<div class="fl-r">
				<ul>
					<?php $modules->printNavigation('system', false); ?>
					<li><a href="<?php echo $cosa->system('base-url'); ?>/?exit" class="logoutlink"><?php $lang->put('logout'); ?></a></li>
				</ul>
			</div>
		</div>
		<div id="navigation">
			<div class="fl-l">
				<h1><a href="<?php echo $cosa->system('base-url'); ?>/"><?php echo $cosa->system('site-title'); ?></a></h1>
				<?php $modules->printNavigation('standard'); ?>
			</div>
			<div class="fl-r">
				<?php $lang->printDropdowns(); ?>
			</div>
		</div>
		<div id="breadcrumb">
			<h2 class="fl-l"><?php $modules->breadcrumb(); ?></h2>
			<div class="fl-r">
				<?php $lang->put('welcome'); ?> <a href="<?php echo $user->authorLink(false, false); ?>"><?php echo $user->getName(); ?></a>
			</div>
		</div>
	</div>
	<div id="main">
		<div class="inner">
			<?php
			
			// create sidebar (if needed)
				if(!$s) $s = $modules->defaultSub();
				$hasSidebar = $modules->createSidebar();
			
			// start module body
				if($hasSidebar) echo '<div id="body">';
			
			// show module messages if there are any
				$modules->printMessages();
			
			// show module view
				include $modules->view();
			
			// end module body
				if($hasSidebar) echo '</div>';
			
			?>
		</div>
	</div>
